home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Learning Director.dcr / UtilsCast_2_MS_MiscUtils.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  2.8 KB  |  130 lines

  1. on RemoveExtension s
  2.   set pos to offset(".", s)
  3.   if pos > 0 then
  4.     set s to chars(s, 1, pos - 1)
  5.   end if
  6.   return s
  7. end
  8.  
  9. on stripWhiteSpace s, where
  10.   if (where = #start) or (where = #both) then
  11.     set pos to 1
  12.     repeat while pos <= length(s)
  13.       set c to char pos of s
  14.       if (c = " ") or (charToNum(c) < 32) then
  15.         set pos to pos + 1
  16.         next repeat
  17.         next repeat
  18.       end if
  19.       exit repeat
  20.     end repeat
  21.     set s to chars(s, pos, length(s))
  22.   end if
  23.   if (where = #end) or (where = #both) then
  24.     set pos to length(s)
  25.     repeat while pos > 0
  26.       set c to char pos of s
  27.       if (c = " ") or (charToNum(c) < 32) then
  28.         set pos to pos - 1
  29.         next repeat
  30.         next repeat
  31.       end if
  32.       exit repeat
  33.     end repeat
  34.     set s to chars(s, 1, pos)
  35.   end if
  36.   return s
  37. end
  38.  
  39. on MyWindow
  40.   set miaw to 0
  41.   set movieName to RemoveExtension(the movie)
  42.   if windowPresent(the movie) then
  43.     set w to window the movie
  44.   else
  45.     if windowPresent(movieName) then
  46.       set w to window movieName
  47.     else
  48.       if windowPresent(the moviePath & movieName) then
  49.         set w to window (the moviePath & movieName)
  50.       else
  51.         set w to VOID
  52.       end if
  53.     end if
  54.   end if
  55.   return w
  56. end
  57.  
  58. on CastLibNumOfMember aMemberNum
  59.   if aMemberNum > 0 then
  60.     set s to string(member aMemberNum)
  61.     set pos to offset("castLib ", s)
  62.     set pos2 to offset(")", s)
  63.     return integer(chars(s, pos + 8, pos2 - 1))
  64.   else
  65.     return 0
  66.   end if
  67. end
  68.  
  69. on ClearPuppets
  70.   set puppetStates to []
  71.   repeat with channelNum = 1 to 48
  72.     puppetSprite(channelNum, 0)
  73.   end repeat
  74. end
  75.  
  76. on SaveAndClearPuppets
  77.   set puppetStates to []
  78.   repeat with channelNum = 1 to 48
  79.     append(puppetStates, the puppet of sprite channelNum)
  80.     puppetSprite(channelNum, 0)
  81.   end repeat
  82.   SG(#gPuppetSaveState, puppetStates)
  83. end
  84.  
  85. on RestorePuppets aMember
  86.   set puppetStates to GG(#gPuppetSaveState)
  87.   repeat with channelNum = 1 to 48
  88.     puppetSprite(channelNum, getAt(puppetStates, channelNum))
  89.   end repeat
  90.   CG(#gPuppetSaveState)
  91. end
  92.  
  93. on isFrameEmpty
  94.   if the frameScript <> 0 then
  95.     return 0
  96.   end if
  97.   if the frameSound1 <> 0 then
  98.     return 0
  99.   end if
  100.   if the frameSound2 <> 0 then
  101.     return 0
  102.   end if
  103.   if the frameTransition <> 0 then
  104.     return 0
  105.   end if
  106.   repeat with num = 1 to 48
  107.     if the memberNum of sprite num <> 0 then
  108.       return 0
  109.     end if
  110.   end repeat
  111.   return 1
  112. end
  113.  
  114. on SetField fieldName, stringValue, fontName, fontSize, fontStyle
  115.   set wasEmpty to 0
  116.   if stringValue = EMPTY then
  117.     set stringValue to " "
  118.     set wasEmpty to 1
  119.   end if
  120.   set the text of field fieldName to stringValue
  121.   if the paramCount > 2 then
  122.     set the textFont of field fieldName to fontName
  123.     set the textSize of field fieldName to fontSize
  124.     set the textStyle of field fieldName to fontStyle
  125.   end if
  126.   if wasEmpty then
  127.     set the text of field fieldName to EMPTY
  128.   end if
  129. end
  130.